// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'

import './assets/js/rem.js'
import '@/assets/css/iconfont.css'
import * as echarts from 'echarts'
import { getQueryString } from '@/utils/util'
import homeApi from './api/homeApi'
Vue.prototype.$echarts = echarts

//import store from './vuex/store'

Vue.config.productionTip = false

import VueChatScroll from 'vue-chat-scroll'

Vue.use(VueChatScroll)

import VueBeautifulChat from 'vue-beautiful-chat'
Vue.use(VueBeautifulChat)

//引入vant
import Vant from 'vant'
import { NavBar } from 'vant'

import 'vant/lib/index.css'
import '@vant/touch-emulator'
Vue.use(Vant)
Vue.use(NavBar)

if (getQueryString('token')) {
  // if(getQueryString('token')&&!localStorage.getItem('isLogin')){
  let token = getQueryString('token')
  localStorage.setItem('token', token)
  // homeApi.getUseInfo({}).then((res)=>{
  //   localStorage.setItem('userId',res.kduserid)
  //   localStorage.setItem('userInfo',JSON.stringify(res))
  // })
}

//引入lazyload
import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload, {
  preLoad: 1.3,
  error: require('./assets/images/loading.png'),
  loading: require('./assets/images/loading.png'),
  attempt: 1,
  // the default is ['scroll', 'wheel', 'mousewheel', 'resize', 'animationend', 'transitionend']
  listenEvents: ['scroll'],
})
router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    // document.title = to.meta.title
    document.title = '保客通'
  }
  // if(localStorage.getItem('userId')){
  //   localStorage.setItem('userId',getQueryString('userId'))
  // }else{
  //   // let userId = 'Kkec3jwhSN27Ruii3LnxBRO33n8='
  //   // localStorage.setItem('userId',userId)
  // }
  next()
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>',
})
